import { Injectable, Output, EventEmitter } from '@angular/core';

import { Observable } from 'rxjs/Observable';
@Injectable()
export class AlertService {

    @Output() gAlert: EventEmitter<any> = new EventEmitter();
    @Output() hideAlert: EventEmitter<any> = new EventEmitter();
    _show(title:string,msg:string,typ:string): Observable<any> {
        var s=this;
        let o = Observable.create(function(observer){
            s.gAlert.emit({title:title,msg:msg,observer:observer,typ:typ});
        });
        return o
    }
    show(msg:string): void {
        
         this._show("提示信息",msg,"alert").subscribe()
         
    }
    showBlock(msg:string): Observable<any>  {
        
         return this._show("提示信息",msg,"alert");
         
    }
    confirm(msg:string): Observable<any>  {
        
         return this._show("提示信息",msg,"confirm");
         
    }
    hide(): void {
        this.hideAlert.emit({hide:true});
    }
    getAlert(): any {
        return this.gAlert;
    }
    getHide(): any {
        return this.hideAlert;
    }
}